#pragma once

struct ServerCell
{
	unsigned int index : 24;
	unsigned int count : 8;
};

struct ServerSpan
{
	unsigned short min;
	unsigned short max;
	unsigned short con;
	unsigned char  mask;
};

struct ServerHeightfield
{
	int spanCount;
	int width;
	int height;
	int bmin[3];
	int bmax[3];
	int cs;
	int ch;
	ServerCell* cells;
	ServerSpan* spans;
};

ServerHeightfield* AllocServerHeightfield();

void FreeServerHeightfield(ServerHeightfield* hf);

bool BuildServerHeightfield(rcContext* ctx, int walkableHeight, int walkableClimb, rcHeightfield& hf, ServerHeightfield& shf);

int GetHeightFieldSpanCount(rcContext* ctx, rcHeightfield& hf);

int GetDirOffsetX(int dir);

int GetDirOffsetY(int dir);